package com.example.oasystem.controller.schedule;

import com.example.oasystem.entity.schedule.AoaScheduleListOfl;
import com.example.oasystem.entity.user.AoaUser;
import com.example.oasystem.service.AoaScheduleListServiceOfl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class AoaScheduleListControllerOfl {

    @Autowired
    AoaScheduleListServiceOfl aoaScheduleListServiceOfl;
    @RequestMapping("/daycalendar")
    public String daycalendar(Model model, HttpServletRequest request){
        return "/daymanage/daycalendar";
    }
    @ResponseBody
    @RequestMapping("/mycalendarload")
    public List<AoaScheduleListOfl> mycalendarload(HttpSession session){
        AoaUser user = (AoaUser) session.getAttribute("user");
        Long userId = user.getUserId();
        List<AoaScheduleListOfl> aoaScheduleList = aoaScheduleListServiceOfl.scheduleList(userId);
        List<AoaScheduleListOfl> otherScheduleList = aoaScheduleListServiceOfl.otherScheduleList(userId);
        aoaScheduleList.addAll(otherScheduleList);
        return aoaScheduleList;
    }
}
